import java.util.Scanner;


public class CrashingBallon {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner inscanner = new Scanner(System.in);	
		
		String pairScores ="";
		while((pairScores = inscanner.nextLine())!= null && !pairScores.isEmpty()) {
			String[] scores = pairScores.split(" ");
			int leftValue = Integer.valueOf(scores[0]);
			int rightValue = Integer.valueOf(scores[1]);
			int winScore = PickWinScore(leftValue,rightValue);
			System.out.println(winScore);
		}
	}

	private static int PickWinScore(int leftValue, int rightValue) {
		int[] leftFactors = new int[100];
		int l = 0;
		int r = 0;
		int tmp = leftValue;
		for(int i =2;i<=100;i++) {
			if (i > tmp) {				
				if (Exists(tmp, leftFactors)) {
					for(int j=0;j<l;j++) {
						if (j*tmp > 100) {
							return rightValue;
						}
						
						if (!Exists(j*tmp, leftFactors)) {
							leftFactors[j] = j*tmp;
							break;
						}
					}
				}
				else {
					leftFactors[l++] = tmp;
				}
				
				break;
			}
			
			if (tmp%i == 0) {
				leftFactors[l++] = i;
				tmp = tmp/i;
			}
		}
		
		if (leftValue > 100) {
			return rightValue;
		}
		
		if (Exists(rightValue, leftFactors)) {
			tmp = rightValue;
			for(int i =0; i< leftFactors.length;i++) {
				if( tmp%leftFactors[i] == 0) {
					tmp = tmp/leftFactors[i];
					if (Exists(tmp, leftFactors)) {
						return leftValue;
					}
				}
			}
			
			return rightValue;
		}
				
		return leftValue;
	}

	private static boolean Exists(int value, int[] values) {
		for(int i=0; i< values.length;i++) {
			if (value == values[i]) {
				return true;
			}
		}
		
		return false;
	}
}
